home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectShow / VBDemo / vbdemo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  32.2 KB  |  790 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmMain 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "DirectShow VB Sample"
  7.    ClientHeight    =   8190
  8.    ClientLeft      =   75
  9.    ClientTop       =   600
  10.    ClientWidth     =   5625
  11.    DrawMode        =   1  'Blackness
  12.    FillStyle       =   0  'Solid
  13.    HasDC           =   0   'False
  14.    Icon            =   "vbdemo.frx":0000
  15.    LinkTopic       =   "frmMain"
  16.    LockControls    =   -1  'True
  17.    MaxButton       =   0   'False
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   8190
  20.    ScaleWidth      =   5625
  21.    Begin MSComctlLib.Toolbar tbControlBar 
  22.       Align           =   1  'Align Top
  23.       Height          =   540
  24.       Left            =   0
  25.       TabIndex        =   20
  26.       Top             =   0
  27.       Width           =   5625
  28.       _ExtentX        =   9922
  29.       _ExtentY        =   953
  30.       ButtonWidth     =   820
  31.       ButtonHeight    =   794
  32.       Appearance      =   1
  33.       ImageList       =   "ctrlImageList"
  34.       _Version        =   393216
  35.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  36.          NumButtons      =   3
  37.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  38.             Key             =   "play"
  39.             Object.ToolTipText     =   "Play"
  40.             ImageIndex      =   1
  41.          EndProperty
  42.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  43.             Key             =   "pause"
  44.             Object.ToolTipText     =   "Pause"
  45.             ImageIndex      =   2
  46.          EndProperty
  47.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  48.             Key             =   "stop"
  49.             Object.ToolTipText     =   "Stop"
  50.             ImageIndex      =   3
  51.          EndProperty
  52.       EndProperty
  53.    End
  54.    Begin VB.PictureBox picVideoWindow 
  55.       Appearance      =   0  'Flat
  56.       BackColor       =   &H00000000&
  57.       BorderStyle     =   0  'None
  58.       DrawMode        =   1  'Blackness
  59.       FillStyle       =   0  'Solid
  60.       ForeColor       =   &H80000008&
  61.       HasDC           =   0   'False
  62.       Height          =   4095
  63.       Left            =   60
  64.       MouseIcon       =   "vbdemo.frx":0442
  65.       MousePointer    =   99  'Custom
  66.       ScaleHeight     =   4095
  67.       ScaleWidth      =   5475
  68.       TabIndex        =   16
  69.       Top             =   660
  70.       Width           =   5475
  71.    End
  72.    Begin VB.Frame fraInfo 
  73.       Caption         =   "Information:"
  74.       Height          =   2055
  75.       Left            =   60
  76.       TabIndex        =   9
  77.       Top             =   6060
  78.       Width           =   5475
  79.       Begin VB.OptionButton optPlaybackRate 
  80.          Caption         =   "Double (200%)"
  81.          Height          =   195
  82.          Index           =   2
  83.          Left            =   3900
  84.          TabIndex        =   2
  85.          ToolTipText     =   "Double Speed"
  86.          Top             =   1680
  87.          Width           =   1335
  88.       End
  89.       Begin VB.OptionButton optPlaybackRate 
  90.          Caption         =   "Normal (100%)"
  91.          Height          =   195
  92.          Index           =   1
  93.          Left            =   2460
  94.          TabIndex        =   1
  95.          ToolTipText     =   "Normal Speed"
  96.          Top             =   1680
  97.          Width           =   1515
  98.       End
  99.       Begin VB.OptionButton optPlaybackRate 
  100.          Caption         =   "Half (50%)"
  101.          Height          =   195
  102.          Index           =   0
  103.          Left            =   1320
  104.          TabIndex        =   0
  105.          ToolTipText     =   "Half Speed"
  106.          Top             =   1680
  107.          Width           =   1215
  108.       End
  109.       Begin VB.TextBox txtDuration 
  110.          BackColor       =   &H8000000F&
  111.          ForeColor       =   &H80000012&
  112.          Height          =   270
  113.          Left            =   1920
  114.          Locked          =   -1  'True
  115.          TabIndex        =   12
  116.          TabStop         =   0   'False
  117.          Top             =   360
  118.          Width           =   3315
  119.       End
  120.       Begin VB.TextBox txtElapsed 
  121.          BackColor       =   &H8000000F&
  122.          ForeColor       =   &H80000012&
  123.          Height          =   270
  124.          Left            =   1920
  125.          Locked          =   -1  'True
  126.          TabIndex        =   11
  127.          TabStop         =   0   'False
  128.          Top             =   720
  129.          Width           =   3315
  130.       End
  131.       Begin VB.TextBox txtRate 
  132.          BackColor       =   &H8000000F&
  133.          ForeColor       =   &H80000012&
  134.          Height          =   270
  135.          Left            =   1920
  136.          Locked          =   -1  'True
  137.          TabIndex        =   10
  138.          TabStop         =   0   'False
  139.          Top             =   1080
  140.          Width           =   3315
  141.       End
  142.       Begin VB.Label lblResetSpeed 
  143.          Caption         =   "Reset speed:"
  144.          Height          =   255
  145.          Left            =   240
  146.          TabIndex        =   17
  147.          Top             =   1680
  148.          Width           =   1095
  149.       End
  150.       Begin VB.Line Line1 
  151.          X1              =   240
  152.          X2              =   5240
  153.          Y1              =   1500
  154.          Y2              =   1500
  155.       End
  156.       Begin VB.Label lblElapsed 
  157.          Caption         =   "Elapsed Time:"
  158.          Height          =   255
  159.          Left            =   240
  160.          TabIndex        =   15
  161.          ToolTipText     =   "Elapsed Time (Seconds)"
  162.          Top             =   720
  163.          Width           =   1575
  164.       End
  165.       Begin VB.Label lblRate 
  166.          Caption         =   "Playback speed:"
  167.          Height          =   255
  168.          Left            =   240
  169.          TabIndex        =   14
  170.          ToolTipText     =   "Playback Speed (Frames Per Second)"
  171.          Top             =   1080
  172.          Width           =   1335
  173.       End
  174.       Begin VB.Label lblDuration 
  175.          Caption         =   "Length:"
  176.          Height          =   255
  177.          Left            =   240
  178.          TabIndex        =   13
  179.          ToolTipText     =   "Media Length (Seconds)"
  180.          Top             =   360
  181.          Width           =   1455
  182.       End
  183.    End
  184.    Begin VB.Frame frameBalance 
  185.       Caption         =   "Balance"
  186.       Height          =   1215
  187.       Left            =   2820
  188.       TabIndex        =   6
  189.       Top             =   4800
  190.       Width           =   2715
  191.       Begin MSComctlLib.Slider slBalance 
  192.          Height          =   495
  193.          Left            =   340
  194.          TabIndex        =   19
  195.          Top             =   300
  196.          Width           =   2000
  197.          _ExtentX        =   3519
  198.          _ExtentY        =   873
  199.          _Version        =   393216
  200.          LargeChange     =   1000
  201.          SmallChange     =   500
  202.          Min             =   -5000
  203.          Max             =   5000
  204.          TickFrequency   =   1000
  205.       End
  206.       Begin VB.Label lblRight 
  207.          Caption         =   "Right"
  208.          Height          =   255
  209.          Left            =   2160
  210.          TabIndex        =   8
  211.          Top             =   840
  212.          Width           =   435
  213.       End
  214.       Begin VB.Label lblLeft 
  215.          Caption         =   "Left"
  216.          Height          =   255
  217.          Left            =   120
  218.          TabIndex        =   7
  219.          Top             =   840
  220.          Width           =   495
  221.       End
  222.    End
  223.    Begin VB.Timer tmrTimer 
  224.       Left            =   1080
  225.       Top             =   8640
  226.    End
  227.    Begin VB.Frame frameVolume 
  228.       Caption         =   "Volume"
  229.       Height          =   1215
  230.       Left            =   60
  231.       TabIndex        =   3
  232.       Top             =   4800
  233.       Width           =   2595
  234.       Begin MSComctlLib.Slider slVolume 
  235.          Height          =   495
  236.          Left            =   340
  237.          TabIndex        =   18
  238.          Top             =   300
  239.          Width           =   2000
  240.          _ExtentX        =   3519
  241.          _ExtentY        =   873
  242.          _Version        =   393216
  243.          LargeChange     =   400
  244.          SmallChange     =   100
  245.          Min             =   -4000
  246.          Max             =   0
  247.          TickFrequency   =   400
  248.       End
  249.       Begin VB.Label lblMax 
  250.          Caption         =   "Max"
  251.          Height          =   255
  252.          Left            =   2100
  253.          TabIndex        =   5
  254.          Top             =   840
  255.          Width           =   375
  256.       End
  257.       Begin VB.Label lblMin 
  258.          Caption         =   "Min"
  259.          Height          =   255
  260.          Left            =   120
  261.          TabIndex        =   4
  262.          Top             =   840
  263.          Width           =   495
  264.       End
  265.    End
  266.    Begin MSComDlg.CommonDialog ctrlCommonDialog 
  267.       Left            =   600
  268.       Top             =   8580
  269.       _ExtentX        =   847
  270.       _ExtentY        =   847
  271.       _Version        =   393216
  272.    End
  273.    Begin MSComctlLib.ImageList ctrlImageList 
  274.       Left            =   0
  275.       Top             =   8580
  276.       _ExtentX        =   1005
  277.       _ExtentY        =   1005
  278.       BackColor       =   -2147483643
  279.       ImageWidth      =   24
  280.       ImageHeight     =   24
  281.       MaskColor       =   12632256
  282.       _Version        =   393216
  283.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  284.          NumListImages   =   3
  285.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  286.             Picture         =   "vbdemo.frx":0594
  287.             Key             =   ""
  288.          EndProperty
  289.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  290.             Picture         =   "vbdemo.frx":06A6
  291.             Key             =   ""
  292.          EndProperty
  293.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  294.             Picture         =   "vbdemo.frx":07B8
  295.             Key             =   ""
  296.          EndProperty
  297.       EndProperty
  298.    End
  299.    Begin VB.Menu mnu_File 
  300.       Caption         =   "&File"
  301.       Begin VB.Menu mnu_FileOpen 
  302.          Caption         =   "&Open"
  303.          Shortcut        =   ^O
  304.       End
  305.       Begin VB.Menu mnuFileSeptum 
  306.          Caption         =   "-"
  307.       End
  308.       Begin VB.Menu mnu_FileExit 
  309.          Caption         =   "E&xit"
  310.       End
  311.    End
  312. Attribute VB_Name = "frmMain"
  313. Attribute VB_GlobalNameSpace = False
  314. Attribute VB_Creatable = False
  315. Attribute VB_PredeclaredId = True
  316. Attribute VB_Exposed = False
  317. '*******************************************************************************
  318. '*       This is a part of the Microsoft DXSDK Code Samples.
  319. '*       Copyright (C) 1999-2001 Microsoft Corporation.
  320. '*       All rights reserved.
  321. '*       This source code is only intended as a supplement to
  322. '*       Microsoft Development Tools and/or SDK documentation.
  323. '*       See these sources for detailed information regarding the
  324. '*       Microsoft samples programs.
  325. '*******************************************************************************
  326. Option Explicit
  327. Option Base 0
  328. Option Compare Text
  329. Private m_dblRate As Double                          'Rate in Frames Per Second
  330. Private m_bstrFileName As String                   'Loaded Filename
  331. Private m_dblRunLength As Double                'Duration in seconds
  332. Private m_dblStartPosition As Double             'Start position in seconds
  333. Private m_boolVideoRunning As Boolean       'Flag used to trigger clock
  334. Private m_objBasicAudio  As IBasicAudio         'Basic Audio Object
  335. Private m_objBasicVideo As IBasicVideo          'Basic Video Object
  336. Private m_objMediaEvent As IMediaEvent        'MediaEvent Object
  337. Private m_objVideoWindow As IVideoWindow   'VideoWindow Object
  338. Private m_objMediaControl As IMediaControl    'MediaControl Object
  339. Private m_objMediaPosition As IMediaPosition 'MediaPosition Object
  340. ' **************************************************************************************************************************************
  341. ' * PRIVATE INTERFACE- FORM EVENT HANDLERS
  342.             ' ******************************************************************************************************************************
  343.             ' * procedure name: Form_Load
  344.             ' * procedure description:  Occurs when a form is loaded.
  345.             ' *
  346.             ' ******************************************************************************************************************************
  347.             Private Sub Form_Load()
  348.             On Local Error GoTo ErrLine
  349.             
  350.             'reset the rate to 1 (normal)
  351.             optPlaybackRate(1).Value = True
  352.             
  353.             'Alter the coordinate system so that we work
  354.             'in pixels (instead of the default twips)
  355.             frmMain.ScaleMode = 3   ' pixels
  356.             
  357.             'Set the granularity for the timer control
  358.             'so that we can display the duration for
  359.             'given video sequence.
  360.             tmrTimer.Interval = 250   '1/4 second intervals
  361.             
  362.             'disable all the control buttons by default
  363.             tbControlBar.Buttons("play").Enabled = False
  364.             tbControlBar.Buttons("stop").Enabled = False
  365.             tbControlBar.Buttons("pause").Enabled = False
  366.             Exit Sub
  367.             
  368. ErrLine:
  369.             Err.Clear
  370.             Exit Sub
  371.             End Sub
  372.             
  373.             
  374.             
  375.             ' ******************************************************************************************************************************
  376.             ' * procedure name: Form_Unload
  377.             ' * procedure description:  Occurs when a form is about to be removed from the screen.
  378.             ' *
  379.             ' ******************************************************************************************************************************
  380.             Private Sub Form_Unload(Cancel As Integer)
  381.             On Local Error GoTo ErrLine
  382.             
  383.             'stop playback
  384.             m_boolVideoRunning = False
  385.             DoEvents
  386.             'cleanup media control
  387.             If Not m_objMediaControl Is Nothing Then
  388.                m_objMediaControl.Stop
  389.             End If
  390.             'clean-up video window
  391.             If Not m_objVideoWindow Is Nothing Then
  392.                m_objVideoWindow.Left = Screen.Width * 8
  393.                m_objVideoWindow.Height = Screen.Height * 8
  394.                m_objVideoWindow.Owner = 0          'sets the Owner to NULL
  395.             End If
  396.             
  397.             'clean-up & dereference
  398.             If Not m_objBasicAudio Is Nothing Then Set m_objBasicAudio = Nothing
  399.             If Not m_objBasicVideo Is Nothing Then Set m_objBasicVideo = Nothing
  400.             If Not m_objMediaControl Is Nothing Then Set m_objMediaControl = Nothing
  401.             If Not m_objVideoWindow Is Nothing Then Set m_objVideoWindow = Nothing
  402.             If Not m_objMediaPosition Is Nothing Then Set m_objMediaPosition = Nothing
  403.             Exit Sub
  404.             
  405. ErrLine:
  406.             Err.Clear
  407.             Exit Sub
  408.             End Sub
  409.             
  410.             
  411.             ' ******************************************************************************************************************************
  412.             ' * procedure name: mnuFileExit_Click
  413.             ' * procedure description:  Occurs when the "Exit" option is invoked from the "File" option on the main menubar.
  414.             ' *
  415.             ' ******************************************************************************************************************************
  416.             Private Sub mnuFileExit_Click()
  417.             Dim frm As Form
  418.             On Local Error GoTo ErrLine
  419.             
  420.             'unload each loaded form
  421.             For Each frm In Forms
  422.                 frm.Move Screen.Width * 8, Screen.Height * 8
  423.                 Unload frm
  424.                 Set frm = Nothing
  425.             Next
  426.             Exit Sub
  427.             
  428. ErrLine:
  429.             Err.Clear
  430.             Exit Sub
  431.             End Sub
  432.             
  433.             
  434.             ' ******************************************************************************************************************************
  435.             ' * procedure name: mnu_FileExit_Click
  436.             ' * procedure description:   Occurs when the user elects the 'Exit' option via the main 'File' menu.
  437.             ' *
  438.             ' ******************************************************************************************************************************
  439.             Private Sub mnu_FileExit_Click()
  440.             Dim frm As Form
  441.             On Local Error GoTo ErrLine
  442.             
  443.             For Each frm In Forms
  444.                frm.Move Screen.Width * 8, Screen.Height * 8
  445.                frm.Visible = False: Unload frm
  446.             Next
  447.             Exit Sub
  448.             
  449. ErrLine:
  450.             Err.Clear
  451.             Exit Sub
  452.             End Sub
  453.             ' ******************************************************************************************************************************
  454.             ' * procedure name: mnu_FileOpen_Click
  455.             ' * procedure description:   Occurs when the user elects the 'Open' option via the main 'File' menu.
  456.             ' *
  457.             ' ******************************************************************************************************************************
  458.             Private Sub mnu_FileOpen_Click()
  459.             Dim nCount As Long
  460.             On Local Error GoTo ErrLine
  461.             
  462.             ' Use the common file dialog to select a media file
  463.             ' (has the extension .AVI or .MPG.)
  464.             ' Initialize global variables based on the
  465.             ' contents of the file:
  466.             '   m_bstrFileName - name of file name selected by the user
  467.             '   m_dblRunLength = length of the file; duration
  468.             '   m_dblStartPosition - point at which to start playing clip
  469.             '   m_objMediaControl, m_objMediaEvent, m_objMediaPosition,
  470.             '   m_objBasicAudio, m_objVideoWindow - programmable objects
  471.             
  472.             'clean up memory (in case a file is already open)
  473.             Call Form_Unload(True)
  474.             
  475.             'Retrieve the name of an .avi or an .mpg
  476.             'file that the user wishes to view.
  477.             ctrlCommonDialog.Filter = "Media Files (*.mpg;*.avi;*.mov;*.wav;*.mp2;*.mp3)|*.mpg;*.avi;*.mov;*.wav;*.mp2;*.mp3"
  478.             ctrlCommonDialog.ShowOpen
  479.             m_bstrFileName = ctrlCommonDialog.FileName
  480.             
  481.             'Instantiate a filter graph for the requested
  482.             'file format.
  483.             Set m_objMediaControl = New FilgraphManager
  484.             Call m_objMediaControl.RenderFile(m_bstrFileName)
  485.             
  486.             'Setup the IBasicAudio object (this
  487.             'is equivalent to calling QueryInterface()
  488.             'on IFilterGraphManager). Initialize the volume
  489.             'to the maximum value.
  490.             
  491.             ' Some filter graphs don't render audio
  492.             ' In this sample, skip setting volume property
  493.             Set m_objBasicAudio = m_objMediaControl
  494.             m_objBasicAudio.Volume = slVolume.Value
  495.             m_objBasicAudio.Balance = slBalance.Value
  496.             
  497.             'Setup the IVideoWindow object. Remove the
  498.             'caption, border, dialog frame, and scrollbars
  499.             'from the default window. Position the window.
  500.             'Set the parent to the app's form.
  501.             Set m_objVideoWindow = m_objMediaControl
  502.             m_objVideoWindow.WindowStyle = CLng(&H6000000)
  503.             m_objVideoWindow.Top = 0
  504.             m_objVideoWindow.Left = 0
  505.             m_objVideoWindow.Width = picVideoWindow.Width
  506.             m_objVideoWindow.Height = picVideoWindow.Height
  507.             'reset the video window owner
  508.             m_objVideoWindow.Owner = picVideoWindow.hWnd
  509.             
  510.             'Setup the IMediaEvent object for the
  511.             'sample toolbar (run, pause, play).
  512.             Set m_objMediaEvent = m_objMediaControl
  513.             
  514.             'Setup the IMediaPosition object so that we
  515.             'can display the duration of the selected
  516.             'video as well as the elapsed time.
  517.             Set m_objMediaPosition = m_objMediaControl
  518.             
  519.             'set the playback rate given the desired optional
  520.             For nCount = optPlaybackRate.LBound To optPlaybackRate.UBound
  521.                If optPlaybackRate(nCount).Value = True Then
  522.                   Select Case nCount
  523.                   Case 0
  524.                          If Not m_objMediaPosition Is Nothing Then _
  525.                             m_objMediaPosition.Rate = 0.5
  526.                   Case 1
  527.                          If Not m_objMediaPosition Is Nothing Then _
  528.                             m_objMediaPosition.Rate = 1
  529.                   Case 2
  530.                          If Not m_objMediaPosition Is Nothing Then _
  531.                             m_objMediaPosition.Rate = 2
  532.                   End Select
  533.                   Exit For
  534.                End If
  535.             Next
  536.             
  537.             m_dblRunLength = Round(m_objMediaPosition.Duration, 2)
  538.             txtDuration.Text = CStr(m_dblRunLength)
  539.             
  540.             ' Reset start position to 0
  541.             m_dblStartPosition = 0
  542.             
  543.             ' Use user-established playback rate
  544.             m_dblRate = m_objMediaPosition.Rate
  545.             txtRate.Text = CStr(m_dblRate)
  546.             
  547.             'enable run buttons by default
  548.             tbControlBar.Buttons("play").Enabled = True
  549.             tbControlBar.Buttons("stop").Enabled = False
  550.             tbControlBar.Buttons("pause").Enabled = False
  551.             
  552.             'run the media file
  553.             Call tbControlBar_ButtonClick(tbControlBar.Buttons(1))
  554.             Exit Sub
  555.             
  556. ErrLine:
  557.             Err.Clear
  558.             Resume Next
  559.             Exit Sub
  560.             End Sub
  561.             
  562.             
  563.             ' ******************************************************************************************************************************
  564.             ' * procedure name: optPlaybackRate_Click
  565.             ' * procedure description:   Indicates that the contents of a control have changed.
  566.             ' *
  567.             ' ******************************************************************************************************************************
  568.             Private Sub optPlaybackRate_Click(Index As Integer)
  569.             On Local Error GoTo ErrLine
  570.             
  571.             'reset textbox
  572.             Select Case Index
  573.             Case 0
  574.                    If Not m_objMediaPosition Is Nothing Then _
  575.                       txtRate.Text = 0.5
  576.             Case 1
  577.                    If Not m_objMediaPosition Is Nothing Then _
  578.                       txtRate.Text = 1
  579.             Case 2
  580.                    If Not m_objMediaPosition Is Nothing Then _
  581.                       txtRate.Text = 2
  582.             End Select
  583.             
  584.             'reset media playback rate
  585.             If Not m_objMediaPosition Is Nothing Then
  586.                Select Case Index
  587.                Case 0
  588.                       If Not m_objMediaPosition Is Nothing Then _
  589.                          m_objMediaPosition.Rate = 0.5
  590.                Case 1
  591.                       If Not m_objMediaPosition Is Nothing Then _
  592.                          m_objMediaPosition.Rate = 1
  593.                Case 2
  594.                       If Not m_objMediaPosition Is Nothing Then _
  595.                          m_objMediaPosition.Rate = 2
  596.                End Select
  597.             End If
  598.             Exit Sub
  599.             
  600. ErrLine:
  601.             Err.Clear
  602.             Exit Sub
  603.             End Sub
  604.             ' ******************************************************************************************************************************
  605.             ' * procedure name: slBalance_Change
  606.             ' * procedure description:   Indicates that the contents of a control have changed.
  607.             ' *
  608.             ' ******************************************************************************************************************************
  609.             Private Sub slBalance_Change()
  610.             On Local Error GoTo ErrLine
  611.             
  612.             'Set the balance using the slider
  613.             If Not m_objMediaControl Is Nothing Then _
  614.                m_objBasicAudio.Balance = slBalance.Value
  615.             Exit Sub
  616.             
  617. ErrLine:
  618.             Err.Clear
  619.             Exit Sub
  620.             End Sub
  621.             
  622.             
  623.             ' ******************************************************************************************************************************
  624.             ' * procedure name: slVolume_Change
  625.             ' * procedure description:   Indicates that the contents of a control have changed.
  626.             ' *
  627.             ' ******************************************************************************************************************************
  628.             Private Sub slVolume_Change()
  629.             On Local Error GoTo ErrLine
  630.             
  631.             'Set the volume using the slider
  632.             If Not m_objMediaControl Is Nothing Then _
  633.                m_objBasicAudio.Volume = slVolume.Value
  634.             Exit Sub
  635.             
  636. ErrLine:
  637.             Err.Clear
  638.             Exit Sub
  639.             End Sub
  640.             
  641.             
  642.             ' ******************************************************************************************************************************
  643.             ' * procedure name: slBalance_MouseMove
  644.             ' * procedure description:    Occurs when the user moves the mouse.
  645.             ' *
  646.             ' ******************************************************************************************************************************
  647.             Private Sub slBalance_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  648.             On Local Error GoTo ErrLine
  649.             
  650.             'Set the balance using the slider
  651.             If Not m_objMediaControl Is Nothing Then _
  652.                m_objBasicAudio.Balance = slBalance.Value
  653.             Exit Sub
  654.             
  655. ErrLine:
  656.             Err.Clear
  657.             Exit Sub
  658.             End Sub
  659.             
  660.             
  661.             ' ******************************************************************************************************************************
  662.             ' * procedure name: slVolume_MouseMove
  663.             ' * procedure description:    Occurs when the user moves the mouse.
  664.             ' *
  665.             ' ******************************************************************************************************************************
  666.             Private Sub slVolume_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  667.             On Local Error GoTo ErrLine
  668.             
  669.             'Set the volume using the slider
  670.             If Not m_objMediaControl Is Nothing Then _
  671.                m_objBasicAudio.Volume = slVolume.Value
  672.             Exit Sub
  673.             
  674. ErrLine:
  675.             Err.Clear
  676.             Exit Sub
  677.             End Sub
  678.             
  679.             
  680.             ' ******************************************************************************************************************************
  681.             ' * procedure name: tbControlBar_ButtonClick
  682.             ' * procedure description:    Occurs when the user clicks on a Button object in a Toolbar control.
  683.             ' *
  684.             ' ******************************************************************************************************************************
  685.             Private Sub tbControlBar_ButtonClick(ByVal Button As Button)
  686.             On Local Error GoTo ErrLine
  687.             
  688.             ' handle buttons on the toolbar
  689.             ' buttons 1, 3 and 5 are defined; 2 and 4 are separators
  690.             ' all DirectShow objects are defined only if the user
  691.             ' has already selected a filename and initialized the objects
  692.             
  693.             ' if the objects aren't defined, avoid errors
  694.             If Not m_objMediaControl Is Nothing Then
  695.                If Button.Key = "play" Then 'PLAY
  696.                   'Invoke the MediaControl Run() method
  697.                   'and pause the video that is being
  698.                   'displayed through the predefined
  699.                   'filter graph.
  700.                   
  701.                   'Assign specified starting position dependent on state
  702.                   If CLng(m_objMediaPosition.CurrentPosition) < CLng(m_dblStartPosition) Then
  703.                       m_objMediaPosition.CurrentPosition = m_dblStartPosition
  704.                   ElseIf CLng(m_objMediaPosition.CurrentPosition) = CLng(m_dblRunLength) Then
  705.                       m_objMediaPosition.CurrentPosition = m_dblStartPosition
  706.                   End If
  707.                   Call m_objMediaControl.Run
  708.                   m_boolVideoRunning = True
  709.                   'enable/disable control buttons
  710.                   tbControlBar.Buttons("play").Enabled = False
  711.                   tbControlBar.Buttons("stop").Enabled = True
  712.                   tbControlBar.Buttons("pause").Enabled = True
  713.                    
  714.                ElseIf Button.Key = "pause" Then  'PAUSE
  715.                   'Invoke the MediaControl Pause() method
  716.                   'and pause the video that is being
  717.                   'displayed through the predefined
  718.                   'filter graph.
  719.                   Call m_objMediaControl.Pause
  720.                   m_boolVideoRunning = False
  721.                   'enable/disable control buttons
  722.                   tbControlBar.Buttons("play").Enabled = True
  723.                   tbControlBar.Buttons("stop").Enabled = True
  724.                   tbControlBar.Buttons("pause").Enabled = False
  725.                   
  726.                ElseIf Button.Key = "stop" Then  'STOP
  727.                   'Invoke the MediaControl Stop() method
  728.                   'and stop the video that is being
  729.                   'displayed through the predefined
  730.                   'filter graph.
  731.                   
  732.                   Call m_objMediaControl.Stop
  733.                   m_boolVideoRunning = False
  734.                   ' reset to the beginning of the video
  735.                   m_objMediaPosition.CurrentPosition = 0
  736.                   txtElapsed.Text = "0.0"
  737.                   'enable/disable control buttons
  738.                   tbControlBar.Buttons("play").Enabled = True
  739.                   tbControlBar.Buttons("stop").Enabled = False
  740.                   tbControlBar.Buttons("pause").Enabled = False
  741.                End If
  742.             End If
  743.             Exit Sub
  744.             
  745. ErrLine:
  746.             Err.Clear
  747.             Exit Sub
  748.             End Sub
  749.             
  750.             
  751.             ' ******************************************************************************************************************************
  752.             ' * procedure name: tmrTimer_Timer
  753.             ' * procedure description:    Occurs when a preset interval for a Timer control has elapsed.
  754.             ' *
  755.             ' ******************************************************************************************************************************
  756.             Private Sub tmrTimer_Timer()
  757.             Dim nReturnCode As Long
  758.             Dim dblPosition As Double
  759.             On Local Error GoTo ErrLine
  760.             'Retrieve the Elapsed Time and
  761.             'display it in the corresponding
  762.             'textbox.
  763.             
  764.             If m_boolVideoRunning = True Then
  765.             
  766.             'obtain return code
  767.                Call m_objMediaEvent.WaitForCompletion(100, nReturnCode)
  768.                
  769.                
  770.                If nReturnCode = 0 Then
  771.                    'get the current position for display
  772.                    dblPosition = m_objMediaPosition.CurrentPosition
  773.                    txtElapsed.Text = CStr(Round(dblPosition, 2))
  774.                Else
  775.                    txtElapsed.Text = CStr(Round(m_dblRunLength, 2))
  776.                    'enable/disable control buttons
  777.                    tbControlBar.Buttons("play").Enabled = True
  778.                    tbControlBar.Buttons("stop").Enabled = False
  779.                    tbControlBar.Buttons("pause").Enabled = False
  780.                    m_boolVideoRunning = False
  781.                End If
  782.             End If
  783.             Exit Sub
  784.             
  785. ErrLine:
  786.             Err.Clear
  787.             Resume Next
  788.             Exit Sub
  789.             End Sub
  790.